package com.example.demo.controller;

import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.jooq.tables.pojos.Email;
import com.example.demo.model.request.EmailPageRequest;
import com.example.demo.model.request.EmailRequest;
import com.example.demo.model.request.VpsPageRequest;
import com.example.demo.model.response.AddressResponse;
import com.example.demo.model.response.EmailResponse;
import com.example.demo.service.order.IEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("v1/email/")
public class EmailController {

    @Autowired
    private IEmailService iEmailService;

    @GetMapping(value = "list")
    public ResultObject<BasePageResponse<EmailResponse>>  queryPageEmailList(EmailPageRequest emailPageRequest) {
        return iEmailService.queryPageEmailList(emailPageRequest);
    }

    @GetMapping(value = "detail")
    public ResultObject<EmailResponse>  queryOneEmail(@RequestParam("emailId") String emailId) {
        return iEmailService.queryOneEmail(emailId);
    }

    /**
     * 邮箱保存
     * @param email 数据对象
     * @return
     */
    @PostMapping(value = "save")
    public ResultObject  saveEmail(@RequestBody EmailRequest email) {
        return iEmailService.saveEmail(email);
    }
}
